
//
//  FRPPhotoViewController.m
//  FunctionalReactivePixels
//
//  Created by Ran on 15/9/7.
//  Copyright (c) 2015年 gintong. All rights reserved.
//

#import "FRPPhotoViewController.h"
#import "FRPPhotoImporter.h"
#import <SVProgressHUD/SVProgressHUD.h>

@interface FRPPhotoViewController ()

@property(nonatomic, strong)FRPPhotoModel *photoModel;
@property(nonatomic, assign)NSInteger photoIndex;

@property(nonatomic, weak)UIImageView *imageView;

@end

@implementation FRPPhotoViewController

- (instancetype)initWithPhotoModel:(FRPPhotoModel *)model photoIndex: (NSInteger)index
{
    if (self = [super init]) {
        
        self.photoModel = model;
        self.photoIndex = index;
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor blackColor];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:imageView];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    self.imageView = imageView;

    self.imageView.image = [UIImage imageWithData:self.photoModel.imageData];
    
//    RAC(imageView, image) = [RACObserve(self.photoModel, imageData) map:^id(id value) {
//        return [UIImage imageWithData:value];
//    }];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    [SVProgressHUD show];
    
    
//    [FRPPhotoImporter fetchPhotoDetails: self.photoModel]
    
}



@end
